// =====================================================================
//
//  This file is part of the Microsoft Dynamics CRM SDK code samples.
//
//  Copyright (C) Microsoft Corporation.  All rights reserved.
//
//  This source code is intended only as a supplement to Microsoft
//  Development Tools and/or on-line documentation.  See these other
//  materials for detailed information regarding Microsoft code samples.
//
//  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//
// =====================================================================
using System;
using System.Runtime.Serialization;

using Microsoft.Xrm.Sdk;

namespace Microsoft.Crm.Sdk.Messages
{
	[DataContract(Namespace = "http://schemas.microsoft.com/crm/2011/Contracts")]
	public sealed class ShareAuditDetail : AuditDetail
	{
		/// <summary>
		/// SecurityPrincipal of the user with whom record is shared
		/// </summary>
		[DataMember]
		public EntityReference Principal { get; set; }

		/// <summary>
		/// Privilges of the user before change.
		/// Return type is AccessRights in all the cases, 
		/// null in a few cases
		/// </summary>
		[DataMember]
		public AccessRights OldPrivileges { get; set; }

		/// <summary>
		/// Privilges of the user after change.
		/// Return type is AccessRights in all the cases, 
		/// null in a few cases
		/// </summary>
		[DataMember]
		public AccessRights NewPrivileges { get; set; }
	}

	[DataContract(Namespace = "http://schemas.microsoft.com/crm/2011/Contracts")]
	public sealed class RolePrivilegeAuditDetail : AuditDetail
	{
		[DataMember]
		public RolePrivilege[] OldRolePrivileges { get; set; }

		[DataMember]
		public RolePrivilege[] NewRolePrivileges { get; set; }

		[DataMember]
		public DataCollection<Guid> InvalidNewPrivileges
		{
			get
			{
				if (_invalidNewPrivileges == null)
				{
					_invalidNewPrivileges = new DataCollection<Guid>();
				}
				return _invalidNewPrivileges;
			}
		}

		private DataCollection<Guid> _invalidNewPrivileges;
	}
}
